import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { uniqueId } from 'lodash';

@Component({
  selector: 'app-pagination',
  templateUrl: './pagination.component.html',
  styles: [
    `
      lv-paginator {
        margin-top: 16px;
      }
    `,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PaginationComponent implements OnInit {
  data;
  pageSizeOptions = [5, 10, 50, 100];
  constructor() {}

  ngOnInit() {
    this.initData();
  }

  initData() {
    this.data = Array.from({ length: 30 }).map((item, key) => this.initUser(key));
  }

  initUser(key: number) {
    return { id: uniqueId('uid'), name: `user${key}`, age: 10 + key, expand: false, random: parseInt(`${Math.random() * 100  }`, 10) };
  }
}
